import { loadEnv } from 'vite'
const config = loadEnv('development', './')
module.exports = {
    hostname: '0.0.0.0',
    port: 10443,
    // Vite 的配置
    // build: { target: "es2015" },

    // 反向代理
    proxy: {
        '/api': {
            // target: 'https://192.168.20.164:8443',
            target: config.VITE_API_HOST,
            changeOrigin: true,
            ws: true,
            secure: false,
            rewrite: path => path.replace(/^\/api/, '')
        },
        '/ai': {
            // target: 'https://103.108.195.112:10443',
            target: `${config.VITE_API_HOST}/ai`,
            changeOrigin: true,
            ws: true,
            secure: false,
            rewrite: path => path.replace(/^\/ai/, '')
        },
        '/ai_s': {
            target: `${config.VITE_API_HOST}/ai_s`,
            changeOrigin: true,
            ws: true,
            secure: false,
            rewrite: path => path.replace(/^\/ai_s/, '')
        },
        '/ws': {
            target: 'ws://192.168.20.179:20080', // 后端WS地址
            ws: true, // 启用websocket代理
            changeOrigin: true,
            secure: false,
            pathRewrite: {
              '^/ws': '/ws' // 保持路径不变
            }
        }
    }
}
//process.env.VITE_API_HOST